package com.kqzz.common.mapper;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.ResultContext;
import org.apache.ibatis.session.ResultHandler;

/**
 * @Description 自定义结果集封装，按照返回的两个字段值为K-V形式
 * @ClassName MapResultHandler.java
 * @Package com.kqzz.oauth2.mapper 
 * @author lipeng
 * @date 2021年4月13日 上午10:35:15
 * 
 * @update_Desc
 * @update_Author
 * @update_Date
 *
 *  ██╗     ██╗    ██████╗ ███████╗███╗   ██╗ ██████╗ 
 *	██║     ██║    ██╔══██╗██╔════╝████╗  ██║██╔════╝ 
 *	██║     ██║    ██████╔╝█████╗  ██╔██╗ ██║██║  ███╗
 *	██║     ██║    ██╔═══╝ ██╔══╝  ██║╚██╗██║██║   ██║
 *	███████╗██║    ██║     ███████╗██║ ╚████║╚██████╔╝
 *	╚══════╝╚═╝    ╚═╝     ╚══════╝╚═╝  ╚═══╝ ╚═════╝
 */
public class MapResultHandler implements ResultHandler {
	
	private List<Map<String,String>> result = new ArrayList<Map<String,String>>();
	
	@Override
	public void handleResult(ResultContext context) {
		// TODO Auto-generated method stub
		Map map = (Map) context.getResultObject();
		Map<String,String> resultMap = new HashMap<String,String>();
		resultMap.put((String) map.get("key"), (String) map.get("value"));
		result.add(resultMap);
	}

	public List<Map<String, String>> getResult() {
		return result;
	}

	public void setResult(List<Map<String, String>> result) {
		this.result = result;
	}
}
